<?php
/**
 * Created by PhpStorm.
 * User: denh
 * Date: 16/5/10
 * Time: 下午5:31
 */
header("content-Type:text/html;charset=utf-8");

define('ADMIN_PATH', __DIR__ . DIRECTORY_SEPARATOR);
define('DEFAULT_CONTROLLER', 'system_config'); #默认控制器
define('DEFAULT_METHOD', 'index'); #默认方法

require_once ADMIN_PATH . '../linhe.php';
require_once ADMIN_PATH . 'controller/BaseController.php';

if (php_sapi_name() == 'cli') {
    $m = isset($argv[1]) ? $argv[1] : DEFAULT_CONTROLLER;
    $a = isset($argv[2]) ? $argv[2] : DEFAULT_METHOD;
} else {
    $m = array_key_exists('m', $_REQUEST) ? $_REQUEST['m'] : DEFAULT_CONTROLLER;
    $a = array_key_exists('a', $_REQUEST) ? $_REQUEST['a'] : DEFAULT_METHOD;
}


define('M', $m);
define('A', $a);
define('NewsCount_PerProcess', 1000); #群发微信消息时，每个进程发送的消息数

$controller = ucfirst($m) . 'Controller';
$controller_dir = ADMIN_PATH . 'controller/' . $controller . '.php';

if (!is_file($controller_dir)) {
    exit('参数 m 错误!');
}
require_once $controller_dir;

$c = new $controller($m, $a);
if (!method_exists($c, $a)) {
    exit('参数 a 错误!');
}

$c->$a();

